﻿using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 纺织贸易管理系统;
using 纺织贸易管理系统.设置窗体;
using 纺织贸易管理系统.选择窗体;

namespace 后整理管理系统.数据分析
{
    public partial class 发货汇总 : Form
    {
        public 发货汇总()
        {
            InitializeComponent();
            dateTimePicker2.Value = DateTime.Now;
            dateTimePicker1.Value =dateTimePicker2.Value .AddDays(-QueryTime.间隔);
        }

        private void txtksmc_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            var fm = new 客户选择() { linkman = new LXR() { MC = txtksmc.Text, ZJC = "" } };
            fm.ShowDialog();
            txtksmc.Text = fm.linkman.MC;
        }
        private void CreateReport()
        {
            try
            {
                gridControl1.DataSource = Connect.CreatConnect().Query($"select ksmc as 客户名称,SUM(TotalMishu) as 发货米数, sum(je) as 发货金额  from DanjuTable  where ksmc like '%{txtksmc.Text }%' and  rq>='{dateTimePicker1.Value.Date  }' and rq<='{dateTimePicker2.Value.Date.AddDays(1)}' and djlx ='{DanjuLeiXing.销售出库单}' group by ksmc order by 发货金额 desc ");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
         }

        private void 发货汇总_Load(object sender, EventArgs e)
        {
            CreateReport();
        }

        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateReport();
        }

        private void 导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExportFile.导出到文件(gridControl1, "发货汇总清单");
        }
    }
}
